﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DevComponents.DotNetBar;
using dataSendModel;
using dataSendModel.Util;

namespace dataSend.ToolForm
{
    public partial class ReaderSetForm : DevComponents.DotNetBar.Office2007Form
    {
        private string equId;
        private ReaderState rs;
        private string readerAdress;
        private MainForm mf;
        public ReaderSetForm(string equId,ReaderState rs,string readerAdress,MainForm mf)
        {
            InitializeComponent();
            this.equId = equId;
            this.rs = rs;
            this.readerAdress = readerAdress;
            this.mf = mf;
        }


        private void ReaderSetForm_Load(object sender, EventArgs e)
        {
            foreach (Control item in this.Controls)
            {
                if (!(item is LabelX) && !(item is ButtonX))
                {
                    item.Text = string.Empty;
                }
            }
            tbEquId.Text = equId;
            tbReaderId.Text = rs.ReaderId;
            tbSign1.Text = rs.Sensitivity1.ToString();
            tbSign2.Text = rs.Sensitivity2.ToString();
            tbTemperature.Text = rs.Temperature.ToString();
            tbUploadTime.Text = rs.UploadTime.ToString();
            tbRecordTime.Text = rs.RecordTime.ToString();
            tbReaderAdress.Text = readerAdress;
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            string readerMsg = CodeConvert.getReaderMsg(tbModiValue.Text, cboModiType.SelectedItem.ToString(), readerAdress);
            short ret = mf.vsOcx.SendComTransmitMsgEx(equId, short.Parse("1"), readerMsg, short.Parse(readerMsg.Length.ToString()));
            string result = ret == 0 ? "修改基站成功" : "修改基站失败";
            mf.setLog("下行基站：" + readerMsg + "，" +result, string.Empty);
        }

        private void buttonX2_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
